if exists('b:undo_ftplugin')
  let b:undo_ftplugin .= '|'
else
  let b:undo_ftplugin = ''
endif

" TODO mapclear <buffer>, temporary use <nowait>
" Define mappings
nnoremap <silent><buffer><expr> <CR> denite#do_map('do_action')
nnoremap <silent><buffer><expr> a denite#do_map('choose_action')
nnoremap <silent><buffer><expr> d denite#do_map('do_action', 'delete')
nnoremap <silent><buffer><expr> p denite#do_map('do_action', 'preview')
nnoremap <silent><buffer><expr> q denite#do_map('quit')
nnoremap <silent><buffer><expr> <esc> denite#do_map('quit')
nnoremap <silent><buffer><expr><nowait> ' denite#do_map('quick_move')
nnoremap <silent><buffer><expr> i denite#do_map('open_filter_buffer')
nnoremap <silent><buffer><expr> <Space> denite#do_map('toggle_select').'j'
nnoremap <silent><buffer><expr> U denite#do_map('do_action', 'dein_update')
nnoremap <silent><buffer><expr> O denite#do_map('do_action', 'dein_open')
" TODO: 全局替换
"nnoremap <silent><buffer><expr> R denite#do_map('do_action', 'replace')

"call denite#custom#map('insert', '<C-r>', '<denite:toggle_matchers:matcher/substring>', 'noremap')
"call denite#custom#map('insert', '<C-s>', '<denite:toggle_sorters:sorter/reverse>', 'noremap')
"call denite#custom#map('normal', 'r', '<denite:do_action:quickfix>', 'noremap')
" call denite#custom#map('insert', ';', 'vimrc#sticky_func()', 'noremap expr')
nnoremap <silent><buffer><expr><nowait> s denite#do_map('do_action', 'split')
